package enumandlambda;

import java.util.concurrent.TimeUnit;

/**
 * @author shkstart
 * @create 2022-12-02-18:41
 */
public class ThreadState {
    public static void main(String[] args) throws InterruptedException {

//        printState();
        Thread t1 = new Thread(()->{
            System.out.println("当前的线程状态2："+
                    Thread.currentThread().getState());
            try {
                TimeUnit.SECONDS.sleep(3);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        System.out.println("当前线程的状态："+ t1.getState());
        t1.start();
        //主线程休息1s
        Thread.sleep(1000);
        System.out.println("当前线程的状态3："+t1.getState());

        t1.join();
        System.out.println("当前线程的状态4："+t1.getState());


    }

    private static void printState() {
        for(Thread.State item : Thread.State.values()){
            System.out.println(item);
        }
    }
}
